<template>
  <el-container>
    <el-header>
      <div>
        <span>111</span>
      </div>
      <el-button type="info" @click="outerLogin">退出</el-button>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse ? '64px':'200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <el-menu
        :unique-opened="true"
          router
          background-color="#333744"
          text-color="#fff"
          active-text-color="#ffd04b"
          :collapse-transition="false"
          :collapse="isCollapse"
        >
          <el-submenu
            :index="index + ''"
            v-for="(item, index) in menus"
            :key="item.index"
          >
            <template slot="title">
              <i :class="icon[index]"></i>
              <span>{{ item.authName }}</span>
            </template>
            <el-menu-item
              :index="childItem.path"
              v-for="childItem in item.children"
              :key="childItem.index"
              >{{ childItem.authName }}</el-menu-item
            >
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// @ is an alias to /src
export default {
  name: "Home",
  components: {},
  created() {
    this.myaxios.get("menus").then((res) => {
      console.log(res);
      this.menus = res.data.data;
    });
  },
  data() {
    return {
      menus: [],
      isCollapse:false,
      icon: {
        0: "el-icon-user-solid",
        1: "el-icon-s-help",
        2: "el-icon-s-goods",
        3: "el-icon-s-fold",
        4: "el-icon-s-shop",
      },
    };
  },
  methods:{
    outerLogin(){
       this.$confirm(' 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
           localStorage.removeItem('token');
        this.$router.push("/")
          this.$message({
            type: 'success',
            message: '成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });          
        });
       
    },
    toggleCollapse(){
      this.isCollapse=!this.isCollapse
    }
  }
};
</script>
<style>

.el-menu{
  border-right:none !important;
  width:90%;
}
.el-container{
  height: 100%;
}
.toggle-button{
  background:#4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  /* text-align: center; */
  letter-spacing: 0.2em;
  cursor: pointer;
}
.el-header{
  background: #373d41;
color: #fff;
padding: 10px;
font-size: 20px;
justify-content: space-between;
display: flex;
align-items: center;
}


.el-aside {
  background-color: #333744;
  color: #333;
  text-align: center;
  line-height: 200px;
}

/* 
body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
} */
</style>